finalize-staged: Ensure /boot automount doesn't expire
authorDan Nicholson <dbn@endlessos.org>
Wed, 16 Feb 2022 22:58:58 +0000 (15:58 -0700)
committerDan Nicholson <dbn@endlessos.org>
Tue, 30 Aug 2022 15:16:39 +0000 (09:16 -0600)
commitf3db79e7fa8d469e539b60ceb7e3d790747e530f
tree58bb4b8909f9dda92ef19a3aa4a668d00ba8cc84
parente30a3b6b17c89f55c33e7985d11ccae7eb173507
finalize-staged: Ensure /boot automount doesn't expire

If `/boot` is an automount, then the unit will be stopped as soon as the
automount expires. That's would defeat the purpose of using systemd to
delay finalizing the deployment until shutdown. This is not uncommon as
`systemd-gpt-auto-generator` will create an automount unit for `/boot`
when it's the EFI System Partition and there's no fstab entry.

To ensure that systemd doesn't stop the service early when the `/boot`
automount expires, introduce a new unit that holds `/boot` open until
it's sent `SIGTERM`. This uses a new `--hold` option for
`finalize-staged` that loads but doesn't lock the sysroot. A separate
unit is used since we want the process to remain active throughout the
finalization run in `ExecStop`. That wouldn't work if it was specified
in `ExecStart` in the same unit since it would be killed before the
`ExecStop` action was run.

Fixes: #2543
Makefile-boot.am
src/boot/ostree-finalize-staged-hold.service [new file with mode: 0644]
src/boot/ostree-finalize-staged.service
src/ostree/ot-admin-builtin-finalize-staged.c
tests/inst/src/destructive.rs
tests/kolainst/destructive/boot-automount.sh [new file with mode: 0755]